//============================================================================
// Name        : cpp_nslookup.cpp
// Author      : khs
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string.h>
#include <netdb.h>
#include <arpa/inet.h>

using namespace std;

int main() {
	struct hostent* ipstruct;

	cout << "input host: ";

	string input;
	cin >> input;

	ipstruct = gethostbyname(input.c_str());

	for(int i=0;ipstruct->h_aliases[i];i++){
		cout << "aliase: " << ipstruct->h_aliases[i] << endl;
	}

	for(int i=0;ipstruct->h_addr_list[i];i++){
		char* ipaddr = inet_ntoa(*(struct in_addr*)ipstruct->h_addr_list[i]);
		cout << ipaddr << endl;
	}

	return 0;
}
